{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "V2fxgc3wpIKM"
      },
      "source": [
        "# 金融市场基础（第22期）第11课书面作业\n",
        "学号：114847\n",
        "\n",
        "**作业内容：**  \n",
        "1.  如下为排好序的资产收益率%，计算资产在90%置信度下的的VaR和条件VaR：  \n",
        "    -16,-14,-10,-7,-7,-5,-4,-4,-3,-1,-1,0,0,0,1,2,2,4,6,7,8,9,11,12,12,14,18,21,23。  \n",
        "2.  简要叙述VaR的优点和缺点"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "X_b6J-CypnHY"
      },
      "source": [
        "## 第1题\n",
        "如下为排好序的资产收益率%，计算资产在90%置信度下的的VaR和条件VaR：  \n",
        "-16,-14,-10,-7,-7,-5,-4,-4,-3,-1,-1,0,0,0,1,2,2,4,6,7,8,9,11,12,12,14,18,21,23。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 282
        },
        "id": "-_StdcBwsnLj",
        "outputId": "19d73f7e-6f68-4fc3-e5db-35354ca2a4b0"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[<matplotlib.lines.Line2D at 0x7ff03a4dc850>]"
            ]
          },
          "execution_count": 7,
          "metadata": {},
          "output_type": "execute_result"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAeqklEQVR4nO3deXxV1b338c+PIYwySZgJAcKsMhgmRxxwKK2orQMWREVB69TaW9tqe23t8Fit1fZpL4gGQUWcqV61KngFVDSQCDJPCYQphEAgAwkZzlnPHxz75GKigXNO9jk73/frxSvn7H3OXr/t1i/blbXXMu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ZbefmS34I+e7Armrvd+OvC+aAD8ws08yme11MhHV2zuWGXu8DOntZTITdZWZrQt05cdelUZ2ZJQPDgXR8ds2OOzfw0XX7ih9C3u/Occ6NAC4H7gx1D/iOO9ZvGN99h//fTKAvMAzIBR73tpyTZ2atgdeBHzvniqrvi/drVsO5+ea6VeeHkN8D9Kz2vkdomy845/aEfu4HFnKse8ov8kL9o1/1k+73uJ6IcM7lOecCzrkg8DRxes3MrCnHQnC+c+6N0GZfXLOazs0v1+14fgj5lUA/M+ttZgnA9cBbHtcUEWbWKvSLIcysFXAJsO6bvxVX3gKmhl5PBd70sJaI+SoEQ64iDq+ZmRmQBmx0zv2l2q64v2a1nZsfrltN4n50DUBoqNOTQGNgjnPuDx6XFBFm1odjd+8ATYAX4/XczGwBMI5jU7rmAQ8B/wReAZI4NsX0tc65uPolZi3nNY5j/8vvgB3AjGr92HHBzM4BPgbWAsHQ5gc41ncd79estnObRJxft5r4IuRFRKRmfuiuERGRWijkRUR8TCEvIuJjCnkRER9TyIuI+JhCXkTExxTyIiI+9v8A8BYBz9f7agUAAAAASUVORK5CYII=",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "needs_background": "light"
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "data = np.array([-16,-14,-10,-7,-7,-5,-4,-4,-3,-1,-1,0,0,0,1,2,2,4,6,7,8,9,11,12,12,14,18,21,23])\n",
        "plt.plot(data)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "weDsNiFquU_h",
        "outputId": "e9dbd01e-ce9b-43ef-d212-5200fb5bc245"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "VaR:  30\n",
            "条件VaR:  15.0\n"
          ]
        }
      ],
      "source": [
        "conf = 0.9\n",
        "datalen = data.shape[0]\n",
        "\n",
        "dataleft = datalen - int(np.ceil(datalen*conf))\n",
        "print('VaR: ',np.sum(-1*data[:dataleft]))\n",
        "print('条件VaR: ',np.mean(-1*data[:dataleft]))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rfh17wy8xXA5"
      },
      "source": [
        "## 第2题\n",
        "简要叙述VaR的优点和缺点"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wa8Lj8TRxgYH"
      },
      "source": [
        "**答：**  \n",
        "* 优点：  \n",
        "  1. 简洁直观，能够一定程度上反应风险下的损益情况。\n",
        "* 缺点：\n",
        "  1. 不能完全反应风险下损益情况，尤其是肥尾情况。\n",
        "  2. 其历史可以推断未来的假设，也是有一定问题的，并不能准确预测未来的情况。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "lJHf3jt6uteM"
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "collapsed_sections": [],
      "name": "fin11",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
